package labox.innovation.loginserver.socket.clientpackets;

import labox.innovation.config.Config;
import labox.innovation.loginserver.LoginController;
import labox.innovation.loginserver.SessionKey;
import labox.innovation.loginserver.socket.serverpackets.LoginFail.LoginFailReason;

/**
 * Fromat is ddc d: first part of session id d: second part of session id c: server ID
 */
public class RequestServerLogin extends LoginClientPacket {
	private int _skey1;

	private int _skey2;

	private int _serverId;

	/**
	 * @return
	 */
	public int getSessionKey1() {
		return _skey1;
	}

	/**
	 * @return
	 */
	public int getSessionKey2() {
		return _skey2;
	}

	/**
	 * @return
	 */
	public int getServerID() {
		return _serverId;
	}

	@Override
	public void readImpl() {
		_skey1 = readInt();
		_skey2 = readInt();
		_serverId = readUnByte();
	}

	/**
	 * @see com.l2jserver.mmocore.network.ReceivablePacket#run()
	 */
	@Override
	public void run() {
//		SessionKey sk = getClient().getSessionKey();
//
//		// if we didnt showed the license we cant check these values
//		if (!Config.SHOW_LICENCE || sk.checkLoginPair(_skey1, _skey2)) {
//			if (LoginController.getInstance().isLoginPossible(getClient(), _serverId)) {
//				getClient().setJoinedGS(true);
//				getClient().sendPacket(new PlayOk(sk));
//			} else {
//				getClient().close(PlayFailReason.REASON_TOO_MANY_PLAYERS);
//			}
//		} else {
//			getClient().close(LoginFailReason.REASON_ACCESS_FAILED);
//		}
	}
}
